package com.japp.manager.service;

import java.io.Serializable;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.japp.base.BaseService;
import com.japp.manager.bean.YjbgBean;
import com.japp.manager.mapper.YjbgMapper;
import com.japp.sys.web.UploadFileAction;
import com.japp.tools.common.JappLog;
import com.japp.tools.page.Page;

/**
 * 研究报告
 * @author Administrator
 *
 */
@Service
@Transactional(rollbackFor=Exception.class)
public class YjbgService implements BaseService{
	@Autowired
	private YjbgMapper yjbgMapper;
	@Autowired
	private UploadFileAction uploadFileAction;
	
	public YjbgBean get(Serializable pk) {
		return null;
	}

	
	public Page<YjbgBean> getPage(Page<YjbgBean> po, YjbgBean obj) {
		try {
			Page<YjbgBean> page = yjbgMapper.getPage(po, obj);
			return page;
		} catch (Exception e) {
			JappLog.log.error("",e);
		}
		return null;
	}

	
	public List<YjbgBean> queryYjbgAll() {
		try {
			return yjbgMapper.queryYjbgAll();
		} catch (Exception e) {
			JappLog.log.error("",e);
		}
		return null;
	}
	
	public YjbgBean findYjbgById(int yjbgId) {
		try {
			return yjbgMapper.findYjbgById(yjbgId);
		} catch (Exception e) {
			JappLog.log.error("",e);
		}
		return null;
	}

	
	public int insertYjbg(YjbgBean yjbg) {
		try {
			int rel = yjbgMapper.insertYjbg(yjbg);
			return rel;
		} catch (Exception e) {
			JappLog.log.error("",e);
		}
		return 0;
	}
	public int deleteYjbg(String[] keys) {
		try {
			int rel = yjbgMapper.deleteYjbg(keys);
			if(rel>0){
				int rels = uploadFileAction.deleteByArray(keys, "TB_YJBG");
				if(rels>0)JappLog.log.info("附件删除成功!");
			}
			return rel;
		} catch (Exception e) {
			JappLog.log.error("",e);
			throw new RuntimeException("123");
		}
	}

	
	public int updateYjbg(YjbgBean yjbg) {
		try {
			return yjbgMapper.updateYjbg(yjbg);
		} catch (Exception e) {
			JappLog.log.error("",e);
		}
		return 0;
	}

}
